package com.demo.bookshelf;

import com.demo.common.model.User;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class BookShelfValidator extends Validator {
    @Override
    protected void validate(Controller controller) {
        validateRequiredString("bookshelf.bookshelfno", "bookshelfnoMsg", "请输入书架号码!");
    }

    @Override
    protected void handleError(Controller controller) {
        controller.keepModel(User.class);

        String actionKey = getActionKey();
        if (actionKey.equals("/bookshelf/save"))
            controller.render("add.html");
        else if (actionKey.equals("/bookshelf/update"))
            controller.render("edit.html");
    }
}
